package com.bc66.tiger.bizsys.menucategories.exception;

import java.util.Properties;



public class MenuCategoriesMsgFactory {
	
	private static final long serialVersionUID = 7998672545514678968L;

	private Integer _errorCode;
	
	private String _errorMessage;
	
	private static Properties _prop;
	
	static{
		
		_prop=(_prop!=null)?_prop:new Properties();
		
		try {
			
			_prop.load(MenuCategoriesMsgFactory.class.getResource("ErrorMessages.properties").openStream());
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			
		}
		
	}

	public MenuCategoriesMsgFactory(){
		
	}
	
	public static String getErrorMessage(Integer errorCode){
		
		return _prop.getProperty(MenuCategoriesErrCode.getErrorName(errorCode));
		
	}
	
	public static MenuCategoriesException create(Integer errorCode){
		
		return create(errorCode,"");
		
	}
	
	public static MenuCategoriesException create(Integer errorCode,String message){
				
		MenuCategoriesException mce=new MenuCategoriesException(errorCode,getErrorMessage(errorCode),message);
		
		return mce;
		
	}
	
	public Integer getErrorCode() {
		return _errorCode;
	}

	public void setErrorCode(Integer errorCode) {
		this._errorCode = errorCode;
	}

	public String getErrorMessage() {
		return _errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this._errorMessage = errorMessage;
	}
	
	public static void main(String[] args) {
		
		try {
			throw MenuCategoriesMsgFactory.create(1003);
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
		}
		
		
		
	}
	
}
